﻿Public Class ListUtil

    Private Sub New()
    End Sub

    Public Shared Sub updateOrAddToList(Of T As Base)(ByRef list As List(Of T), ByRef entity As T)
        Dim tempList As New List(Of T)
        Dim updated As Boolean = False
        For Each e As T In list
            If e.id <> entity.id Then
                tempList.Add(e)
            Else
                ' if id existierte...
                tempList.Add(entity)
                updated = True
            End If
        Next
        If Not updated Then
            tempList.Add(entity)
        End If
        list.Clear()
        list.AddRange(tempList)
    End Sub

End Class
